#ifndef _H_EUREKA_WINDOW
#define _H_EUREKA_WINDOW

#include <KXmlGuiWindow>
#include <ktabwidget.h>
#include <kurl.h>
#include <kparts/part.h>
#include <kparts/browserextension.h>
#include <QList>
#include <QProgressBar>
#include <kprocess.h>
#include <KLineEdit>
#include <kaction.h>
#include "page.h"

class EurekaWindow : public KXmlGuiWindow
{
    Q_OBJECT

public:
    EurekaWindow( QWidget *parent = 0 );

public slots:
    void open( const KUrl& url, const KParts::OpenUrlArguments& arguments = KParts::OpenUrlArguments(), const KParts::BrowserArguments& browserArguments = KParts::BrowserArguments() );
    inline void newTab() { open(  KUrl(  "about:blank" ) ); }
    inline void newWindow( const KUrl& url ) { KProcess::execute(  "xdg-open", QStringList() << url.url() ); }
    void closeTab( QWidget* page );
    inline void closeTab() { closeTab(  pages->currentWidget() ); }
    inline void setCurrentTabText( const QString & label ) { pages->setTabText(  pages->currentIndex(), label ); }
    bool queryClose();
    inline void back() { pages->currentWidget()->findChild<Page*>()->back(); }
    inline void forward() { pages->currentWidget()->findChild<Page*>()->forward(); }
    inline void reload() { pages->currentWidget()->findChild<Page*>()->reload(); }
    inline void stop() { pages->currentWidget()->findChild<Page*>()->stop(); }

private:
    KTabWidget *pages;
    QList<KUrl> history;
    QList<KUrl> future;
    QStringList mimes;
    KLineEdit* addressBar;
    QProgressBar* progressBar;
    KAction* stopAction;
    KAction* reloadAction;

private slots:
    void setupActions();
    void currentTabChanged( int index );
    void addressBarGo();

};

#endif

